---
category: Number
created: '2020-05-05'
title: Subtract arguments
updated: '2021-10-13'
---

**JavaScript version**

```js subtract.js
const subtract = (...args) => args.reduce((a, b) => a - b);
```

**TypeScript version**

```ts subtract.ts
const subtract = (...args: number[]): number => args.reduce((a, b) => a - b);
```

**Examples**

```js examples.js
subtract(1, 2, 3, 4); // -8
```
